package com.example.actordemo2.remote;


import akka.actor.AbstractActor;
import akka.actor.ActorRef;
import akka.actor.ActorSelection;
import akka.actor.ActorSystem;
import akka.util.Timeout;
import com.example.actordemo2.config.SpringExtension;
import com.typesafe.config.ConfigFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import java.time.Duration;
import java.util.concurrent.TimeUnit;

@Component
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class RemoteCustomer  extends AbstractActor {

    @Autowired
    SpringExtension springExtension;
    @Override
    public Receive createReceive() {
        return receiveBuilder().matchAny(o->{
            System.out.println("远程调用");

            ActorSelection selection =
                    getContext().actorSelection("akka.tcp://dc_actor1@127.0.0.1:2552/user/remoteActor");
            selection.tell("111", selection.anchor());

        }).build();
    }


}
